<!DOCTYPE html>
<!--根标签  标签属性-->
<!--三个部分：结构（html标签）、表现（CSS）、行为（javascript--jquery框架）-->
<html lang="en">
<head><!--头部-->
    <meta charset="UTF-8">
    <title>首页</title>
    <!--样式标签-->
    <style>
        .blue-b {
            background: #19a8cc;
            width: 100%;
            position: relative;
            min-height: 1px;
            padding-right: 15px;
            padding-left: 15px;
        }
        .navbar-brand {
            padding: 15px 15px;
            font-size: 18px;
            line-height: 20px;
        }
        input {
            display: block;
        }
    </style>
    <!--引入js文件-->
    <script src="js/jquery.js"></script>
</head>
<!--身体：展示网页内容-->
<body>

<!--div页面结构的划分  style属性：样式-->
<div>
    <div style="padding: 0; margin: 0; display: block;">
        <div class="blue-b">
            <a>
                <img class="navbar-brand"  style="padding: 8px 40px;"  src="imgs/logo.png">
            </a>
        </div>
    </div>
    <div>
        <form style="padding: 0; margin-top: 5px; display: block;" >
            <input type="text" required="required" placeholder="用户名" name="u">
            <input type="password" required="required" placeholder="密码" name="p">

        </form>
        <button id="login" class="but" type="button" >登录</button>
    </div>
</div>
<script>

    $("#login").click(function(){
        let user =  $("input[name='u']").val();
        let password =  $("input[name='p']").val();
        $.ajax({
            url:"login?u=" + user + "&p=" + password,
            type:"POST",
            success:function({code, msg}){  /*返回值可以直接使用大括号解析*/
                if (code == 200) {
                    window.location.href = '/index.html';
                } else {
                    alert(msg);
                }
            }
        });
    })
</script>
</body>
</html>